public class SolutionLCP61 {
    public int temperatureTrend(int[] temperatureA, int[] temperatureB) {
        int[] a=new int[temperatureA.length-1];
        int[] b=new int[temperatureB.length-1];
        for (int i=0;i<a.length;i++){
            if (temperatureA[i]-temperatureA[i+1]<0){
                a[i]=1;
            }else if (temperatureA[i]-temperatureA[i+1]==0) {
                a[i]=0;
            }else {
                a[i]=-1;
            }
            if (temperatureB[i]-temperatureB[i+1]<0){
                b[i]=1;
            }else if (temperatureB[i]-temperatureB[i+1]==0) {
                b[i]=0;
            }else {
                b[i]=-1;
            }
        }
        int ans=0;
        for (int i=0;i<a.length;i++){
            int t=0;
            while (i<a.length && a[i]==b[i]){
                t++;
                i++;
            }
            ans=Math.max(ans,t);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new SolutionLCP61().temperatureTrend(new int[]{21,18,18,18,31},new int[]{34,32,16,16,17}));
    }
}
